package com.ys.controller.api.outer;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.tomcat.util.http.fileupload.FileUploadException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.ys.service.sys.UploadService;

@Controller
@RequestMapping("/api/outer/upload")
public class ApiOuterUploadController {
	
    @Autowired
    private UploadService uploadService;

	@RequestMapping("/uploadfileForEditor")
	public void uploadfileForEditor(Model model, HttpServletRequest request, HttpServletResponse response,
			@RequestParam("fileStream") MultipartFile file) throws FileUploadException, IOException {

		uploadService.uploadfileForEditor(request, response, file);
	}

	@RequestMapping("/uploadfileForLayer")
	@ResponseBody
	public void uploadfileForLayer(Model model, HttpServletRequest request, HttpServletResponse response,
			@RequestParam("file") MultipartFile file) throws FileUploadException, IOException {

		uploadService.uploadfileForLayer(response, file);
	}
}
